import { priviateAccount, userUnitid, accountUnitIds, unitidCompany } from "@src/config/accountInfo"

import { PrivateCodeConfig } from "./type";

export const getPrivateCommonParams = ({
  sourceId = 1,
  source = '山东交易中心',
  thirdId = userUnitid[priviateAccount],
  thirdName = '未知公司'
}) => ({sourceId,source,thirdId,thirdName: unitidCompany?.[thirdId] || thirdName})

export const arrHasVal = (arr:any[]) => {
  return arr.some(val => val !== null && val !== undefined && val !== '')
}

export enum SMPrivateCodes {
  // NODE_ELECTRICITY_PRICE_TEMPORARY = 'node_electricity_price_temporary', // 【现货市场】-【现货交易】-【实时交易结果】-【实时交易结果查询（临时）丰泽

  // DAY_TRADING_RESULT = 'day_trading_result',  // 【现货市场】-【现货交易】-【日前交易结果】-【一次日前交易结果查询（新版）】-电量、出清电价

  DAY_TRADING_RESULT_OUTPUT = 'day_trading_result_output', // 【现货市场】-【现货交易】-【日前交易结果】-【一次日前交易结果查询】出力
  DAY_TRADING_RESULT_QUAN = 'day_trading_result_quan',  // 【现货市场】-【现货交易】-【日前交易结果】-【一次日前交易结果查询】电量
  DAY_TRADING_RESULT_PRICE = 'day_trading_result_price', // 现货市场】-【现货交易】-【日前交易结果】-【一次日前交易结果查询】 电价 (发电)

  DAY_TWO_TRADING_RESULT_OUTPUT = 'day_two_trading_result_output', // 【现货市场】-【现货交易】-【日前交易结果】-【日前交易结果查询】出力
  DAY_TWO_TRADING_RESULT_QUAN = 'day_two_trading_result_quan',  // 【现货市场】-【现货交易】-【日前交易结果】-【日前交易结果查询】电量
  DAY_TWO_TRADING_RESULT_PRICE = 'day_two_trading_result_price', // 现货市场】-【现货交易】-【日前交易结果】-【日前交易结果查询】 电价 (发电)
  
  REALTIME_TRADING_RESULT_OUTPUT = 'realtime_trading_result_output', // 【现货市场】-【现货交易】-【实时交易结果】-【实时交易结果查询（正式数据）】出力
  REALTIME_TRADING_RESULT_QUAN = 'realtime_trading_result_quan',  // 【现货市场】-【现货交易】-【实时交易结果】-【实时交易结果查询（正式数据）】电量
  REALTIME_TRADING_RESULT_PRICE = 'realtime_trading_result_price',  // 【现货市场】-【现货交易】-【实时交易结果】-【实时交易结果查询（正式数据）】电价 (发电)

  QUOTATION_CURVE = 'quotation_curve', // 【日前交易申报】-【电能量申报查询】

  QUOTATION_OPERATING_PARAMETER = 'quotation_operating_parameter' // 【日前交易申报】-【电能量申报查询】- 运行参数
}

export const SMPrivateCodeConfig:Partial<Record<SMPrivateCodes, PrivateCodeConfig>> = {

  // // 【现货市场】-【现货交易】-【日前交易结果】-【一次日前交易结果查询（新版）】-电量、出清电价
  // [SMPrivateCodes.DAY_TRADING_RESULT]: {
  //   saveType: 'json',
  //   getType: 'json',
  //   dataDate: 1,
  //   dataTime: ['19:00','19:15','19:30','19:45','20:00', '20:15','20:30','20:45','21:00'],
  // },

  [SMPrivateCodes.DAY_TRADING_RESULT_OUTPUT]: {
    saveType: 'json',
    getType: 'json',
    dataDate: 1,
    dataTime: [],
    fnName: 'getSavePrivateDayOutputQuan',
    dataItemName: '日前出清出力、电量'
  },
  [SMPrivateCodes.DAY_TRADING_RESULT_QUAN]: {
    saveType: 'json',
    getType: 'json',
    dataDate: 1,
    dataTime: [],
    fnName: 'getSavePrivateDayOutputQuan',
    dataItemName: ''
  },
  [SMPrivateCodes.DAY_TRADING_RESULT_PRICE]: {
    saveType: 'json',
    getType: 'json',
    dataDate: 1,
    dataTime: [],
    realUnitId: accountUnitIds[userUnitid[priviateAccount]]?.company1, // 发电
    fnName: 'getSavePrivateDayPrice',
    dataItemName: '日前出清电价'
  },

  [SMPrivateCodes.DAY_TWO_TRADING_RESULT_OUTPUT]: {
    saveType: 'json',
    getType: 'json',
    dataDate: 1,
    dataTime: [],
    fnName: 'getSavePrivateDayTwoOutputQuan',
    dataItemName: '二次日前出清出力、电量'
  },
  [SMPrivateCodes.DAY_TWO_TRADING_RESULT_QUAN]: {
    saveType: 'json',
    getType: 'json',
    dataDate: 1,
    dataTime: [],
    fnName: 'getSavePrivateDayTwoOutputQuan',
    dataItemName: ''
  },
  [SMPrivateCodes.DAY_TWO_TRADING_RESULT_PRICE]: {
    saveType: 'json',
    getType: 'json',
    dataDate: 1,
    dataTime: [],
    realUnitId: accountUnitIds[userUnitid[priviateAccount]]?.company1, // 发电
    fnName: 'getSavePrivateDayTwoPrice',
    dataItemName: '二次日前出清电价'
  },

  [SMPrivateCodes.REALTIME_TRADING_RESULT_OUTPUT]: {
    saveType: 'json',
    getType: 'json',
    dataDate: -1,
    dataTime: [],
    fnName: 'getSavePrivaterRealtimeOutputQuan',
    dataItemName: '实时出清出力、电量'
  },

  [SMPrivateCodes.REALTIME_TRADING_RESULT_QUAN]: {
    saveType: 'json',
    getType: 'json',
    dataDate: -1,
    dataTime: [],
    fnName: 'getSavePrivaterRealtimeOutputQuan',
    dataItemName: ''
  },

  [SMPrivateCodes.REALTIME_TRADING_RESULT_PRICE]: {
    saveType: 'json',
    getType: 'json',
    dataDate: -1,
    dataTime: [],
    realUnitId: accountUnitIds[userUnitid[priviateAccount]]?.company1, // 发电
    fnName: 'getSavePrivaterRealtimePrice',
    dataItemName: '实时出清电价'
  },

  [SMPrivateCodes.QUOTATION_CURVE]: {
    saveType: 'json',
    getType: 'json',
    dataDate: 1,
    dataTime: [],
    fnName: 'getSaveTradeReportQuatation',
    dataItemName: '日前交易申报'
  },

  [SMPrivateCodes.QUOTATION_OPERATING_PARAMETER]: {
    saveType: 'json',
    getType: 'json',
    dataDate: 1,
    dataTime: [],
    fnName: 'getSaveTradeReportOperatingParameter',
    dataItemName: '日前交易申报-运行参数'
  }

}
